/*
* $Id: RecordViewSettings.cpp 70 2010-03-20 20:21:36Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "RecordViewSettings.h"
#include "../SettingControlIds.h"
#include "Settings/DinIntDefined.h"
#include "Database/Tables/UserFieldsTable.h"
#include "Event/EventId.h"

#define RECORD_VIEW_REG_NAME	_T("Software\\Apiary\\RecordViewSettings")

CRecordViewSettings::CRecordViewSettings()
: CSettingsWithUserColumn(RECORD_VIEW_ID, RECORD_VIEW_REG_NAME, FALSE){
	Init();
}
CRecordViewSettings::~CRecordViewSettings(){}

std::map<std::tstring, std::tstring> CRecordViewSettings::GetStates(){
	std::map<std::tstring, std::tstring> aStates = __super::GetStates();
	aStates.insert(aStates.end(), std::make_pair(STATIC_HEADER1_ID, IApplication::GetApp()->GetLanguageManager()->GetString(SETTINGS_ID)));
	aStates.insert(aStates.end(), std::make_pair(STATIC_VIEW_ID, IApplication::GetApp()->GetLanguageManager()->GetString(VIEW_COLUMN_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_GOODS_HONEY_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_GOODS_HONEY_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_PUMP_HONEY_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_PUMP_HONEY_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_FEEDING_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_FEEDING_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_SEAL_BROOD_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_SEAL_BROOD_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_OPEN_BROOD_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_OPEN_BROOD_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_GIVE_WOX_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_GIVE_WOX_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_NOTE_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_NOTE_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_DISEASES_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_DISEASES_ID)));
	aStates.insert(aStates.end(), std::make_pair(CHECK_AMBROSIA_ID, CCommonFunction::GetRegValue(RECORD_VIEW_REG_NAME, CHECK_AMBROSIA_ID)));
	return aStates;
}

std::map<std::tstring, std::tstring> CRecordViewSettings::GetDefaultStates(){
	std::map<std::tstring, std::tstring> aDefault;
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_GOODS_HONEY_ID, CHECK_BOX_STATE_2));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_PUMP_HONEY_ID, CHECK_BOX_STATE_1));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_FEEDING_ID, CHECK_BOX_STATE_1));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_SEAL_BROOD_ID, CHECK_BOX_STATE_2));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_OPEN_BROOD_ID, CHECK_BOX_STATE_2));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_GIVE_WOX_ID, CHECK_BOX_STATE_1));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_NOTE_ID, CHECK_BOX_STATE_1));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_DISEASES_ID, CHECK_BOX_STATE_1));
	aDefault.insert(aDefault.end(), std::make_pair(CHECK_AMBROSIA_ID, CHECK_BOX_STATE_2));
	return aDefault;
}

std::map<std::tstring, std::vector<Parameter> > CRecordViewSettings::GetParameters(){
	std::map<std::tstring, std::vector<Parameter> > aMapParameters = __super::GetParameters();
	std::vector<Parameter> aParameters;

	//static_header1     
	aParameters.push_back(Parameter(TYPE, HEADER));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(STATIC_HEADER1_ID, aParameters));

	//static_view
	aParameters.clear();
	aMapParameters.insert(aMapParameters.end(), std::make_pair(STATIC_VIEW_ID, aParameters));

	//check_boxes
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_GOODS_HONEY_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_PUMP_HONEY_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_FEEDING_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_SEAL_BROOD_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_OPEN_BROOD_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_GIVE_WOX_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_NOTE_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_DISEASES_ID, aParameters));
	aMapParameters.insert(aMapParameters.end(), std::make_pair(CHECK_AMBROSIA_ID, aParameters));

	return aMapParameters;
}

std::vector<Window> CRecordViewSettings::GetWindows(){
	std::vector<Window> aWindows = __super::GetWindows();
	aWindows.push_back(Window(STATIC, 10, 0, 415, 23, SS_CENTER, IApplication::GetApp()->GetLanguageManager()->GetString(SETTINGS_ID), STATIC_HEADER1_ID));
	aWindows.push_back(Window(STATIC, 10, 30, 415, 15, SS_LEFT, IApplication::GetApp()->GetLanguageManager()->GetString(VIEW_COLUMN_ID), STATIC_VIEW_ID));
	aWindows.push_back(Window(CHECK_BOX, 10, 45, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(GOODS_HONEY_ID), CHECK_GOODS_HONEY_ID));
	aWindows.push_back(Window(CHECK_BOX, 215, 45, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(PUMP_HONEY_ID), CHECK_PUMP_HONEY_ID));
	aWindows.push_back(Window(CHECK_BOX, 10, 65, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(FEEDING_ID), CHECK_FEEDING_ID));
	aWindows.push_back(Window(CHECK_BOX, 215, 65, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(SEAL_BROOD_ID), CHECK_SEAL_BROOD_ID));
	aWindows.push_back(Window(CHECK_BOX, 10, 85, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(OPEN_BROOD_ID), CHECK_OPEN_BROOD_ID));
	aWindows.push_back(Window(CHECK_BOX, 215, 85, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(GIVE_WOX_ID), CHECK_GIVE_WOX_ID));
	aWindows.push_back(Window(CHECK_BOX, 10, 105, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(AMBROSIA_ID), CHECK_AMBROSIA_ID));
	aWindows.push_back(Window(CHECK_BOX, 215, 105, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(DISEASES_ID), CHECK_DISEASES_ID));
	aWindows.push_back(Window(CHECK_BOX, 10, 125, 200, 20, NULL, IApplication::GetApp()->GetLanguageManager()->GetString(COLUMN_NOTE_ID), CHECK_NOTE_ID));
	return aWindows;
}

void CRecordViewSettings::PostSave(){
	IApplication::GetApp()->GetEventManager()->SendEvent(INSPECT_STN_CHANGE_EVENT);
}

int CRecordViewSettings::GetTypeTable(){
	return CUserFieldsTable::content::INSPECT;
}

CRect CRecordViewSettings::GetSizeRegion(){
	return CRect(CPoint(10, 150), CSize(250, 245));
}
